<?php

use Illuminate\Support\Facades\Route;


// 不登录也可以进入
Route::group(
    ['middleware' => 'guest:manage'],
    function () {
        Route::post('login', 'AuthController@login');
        Route::put('refresh', 'AuthController@refresh');
    }
);

// 登录才可以进入
Route::group(
    ['middleware' => 'auth:manage'],
    function () {
        Route::delete('logout', 'AuthController@logout');
        Route::get('profile/logs', 'AuthController@logs');
        Route::get('profile', 'AuthController@profile');
        Route::put('profile/password', 'AuthController@password');
    }
);
// 要验证权限
Route::group(
    ['middleware' => ['rbac:manage', 'auth:manage'], 'prefix' => 'customer'],
    function () {
        Route::get('index', 'Customer\IndexController@index');
        Route::post('index', 'Customer\IndexController@store');
        Route::get('index/{id}', 'Customer\IndexController@edit');
        Route::put('index/{id}', 'Customer\IndexController@update');
        Route::get('account/{id}', 'Customer\IndexController@getAccount');
        Route::post('account/{id}', 'Customer\IndexController@account');
});

// 要验证权限
Route::group(
    ['middleware' => ['rbac:manage', 'auth:manage'], 'prefix' => 'customer/authorities'],
    function () {
        Route::get('menu/authority', 'Customer\Authorities\MenuController@authority')->name('role.menu_authority');
        Route::get('menu', 'Customer\Authorities\MenuController@index')->name('menu.index');
        Route::get('menu/create', 'Customer\Authorities\MenuController@create')->name('menu.store');
        Route::get('menu/{id}/edit', 'Customer\Authorities\MenuController@edit')->name('menu.update');
        Route::post('menu', 'Customer\Authorities\MenuController@store')->name('menu.store');
        Route::put('menu/{id}', 'Customer\Authorities\MenuController@update')->name('menu.update');
        Route::delete('menu/{id}', 'Customer\Authorities\MenuController@destroy')->name('menu.destroy');

        Route::get('authority', 'Customer\Authorities\AuthorityController@index')->name('authority.index');
        Route::get('authority/{id}/edit', 'Customer\Authorities\AuthorityController@edit')->name('authority.update');
        Route::post('authority', 'Customer\Authorities\AuthorityController@store')->name('authority.store');
        Route::put('authority/{id}', 'Customer\Authorities\AuthorityController@update')->name('authority.update');
        Route::delete('authority/{id}', 'Customer\Authorities\AuthorityController@destroy')->name('authority.destroy');

    });


Route::group(
    ['prefix' => 'system/dictionary', 'middleware' => ['manage', 'rbac:manage', 'logs:manage'], 'namespace' => 'System\Dictionary'],
    function () {
        Route::get("country", "CountryController@index")->name('system.dictionary.country.index');
        Route::post("country", "CountryController@store")->name('system.dictionary.country.store');
        Route::get("country/{id}/edit", "CountryController@edit")->name('system.dictionary.country.edit');
        Route::put("country/{id}", "CountryController@update")->name('system.dictionary.country.update');

        Route::get("currency", "CurrencyController@index")->name('system.dictionary.currency.index');
        Route::post("currency", "CurrencyController@store")->name('system.dictionary.currency.store');
        Route::get("currency/{id}/edit", "CurrencyController@edit")->name('system.dictionary.currency.edit');
        Route::put("currency/{id}", "CurrencyController@update")->name('system.dictionary.currency.update');

        Route::get("port", "PortController@index")->name('system.dictionary.port.index');
        Route::post("port", "PortController@store")->name('system.dictionary.port.store');
        Route::get("port/{id}/edit", "PortController@edit")->name('system.dictionary.port.edit');
        Route::put("port/{id}", "PortController@update")->name('system.dictionary.port.update');

        Route::get("unit", "UnitController@index")->name('system.dictionary.unit.index');
        Route::post("unit", "UnitController@store")->name('system.dictionary.unit.store');
        Route::get("unit/{id}/edit", "UnitController@edit")->name('system.dictionary.unit.edit');
        Route::put("unit/{id}", "UnitController@update")->name('system.dictionary.unit.update');

        Route::get("packing", "PackingController@index")->name('system.dictionary.packing.index');
        Route::post("packing", "PackingController@store")->name('system.dictionary.packing.store');
        Route::get("packing/{id}/edit", "PackingController@edit")->name('system.dictionary.packing.edit');
        Route::put("packing/{id}", "PackingController@update")->name('system.dictionary.packing.update');

        Route::get("transport", "TransportController@index")->name('system.dictionary.transport.index');
        Route::post("transport", "TransportController@store")->name('system.dictionary.transport.store');
        Route::get("transport/{id}/edit", "TransportController@edit")->name('system.dictionary.transport.edit');
        Route::put("transport/{id}", "TransportController@update")->name('system.dictionary.transport.update');

        Route::get("express", "ExpressController@index")->name('system.dictionary.express.index');
        Route::post("express", "ExpressController@store")->name('system.dictionary.express.store');
        Route::get("express/{id}/edit", "ExpressController@edit")->name('system.dictionary.express.edit');
        Route::put("express/{id}", "ExpressController@update")->name('system.dictionary.express.update');

        Route::get("hs_code", "HsCodeController@index")->name('system.dictionary.hs_code.index');
        Route::post("hs_code", "HsCodeController@store")->name('system.dictionary.hs_code.store');
        Route::get("hs_code/{id}/edit", "HsCodeController@edit")->name('system.dictionary.hs_code.edit');
        Route::put("hs_code/{id}", "HsCodeController@update")->name('system.dictionary.hs_code.update');

        Route::get("area", "AreaController@index")->name('system.dictionary.area.index');

        Route::get("basics", "BasicsController@index")->name('system.dictionary.basics.index');
        Route::post("basics", "BasicsController@store")->name('system.dictionary.basics.store');
        Route::get("basics/{id}/edit", "BasicsController@edit")->name('system.dictionary.basics.edit');
        Route::put("basics/{id}", "BasicsController@update")->name('system.dictionary.basics.update');

    });

// 要验证权限
Route::group(
    ['middleware' => ['rbac:manage', 'auth:manage'], 'prefix' => 'authorities'],
    function () {
        Route::get('menu/authority', 'Authorities\MenuController@authority')->name('role.menu_authority');

        Route::get('role', 'Authorities\RoleController@index')->name('role.index');
        Route::get('role/{id}/edit', 'Authorities\RoleController@edit')->name('role.update');
        Route::get('role/create', 'Authorities\RoleController@create')->name('role.store');
        Route::post('role', 'Authorities\RoleController@store')->name('role.store');
        Route::put('role/{id}', 'Authorities\RoleController@update')->name('role.update');
        Route::delete('role/{id}', 'Authorities\RoleController@destroy')->name('role.destroy');


        Route::put('user/{user}/status', 'Authorities\UserController@status')->name('user.update');

        Route::get('user', 'Authorities\UserController@index')->name('user.index');
        Route::get('user/create', 'Authorities\UserController@create')->name('user.store');
        Route::get('user/{id}/edit', 'Authorities\UserController@edit')->name('user.update');
        Route::post('user', 'Authorities\UserController@store')->name('user.store');
        Route::put('user/{id}', 'Authorities\UserController@update')->name('user.update');

        Route::get('menu', 'Authorities\MenuController@index')->name('menu.index');
        Route::get('menu/create', 'Authorities\MenuController@create')->name('menu.store');
        Route::get('menu/{id}/edit', 'Authorities\MenuController@edit')->name('menu.update');
        Route::post('menu', 'Authorities\MenuController@store')->name('menu.store');
        Route::put('menu/{id}', 'Authorities\MenuController@update')->name('menu.update');
        Route::delete('menu/{id}', 'Authorities\MenuController@destroy')->name('menu.destroy');

        Route::get('authority', 'Authorities\AuthorityController@index')->name('authority.index');
        Route::get('authority/{id}/edit', 'Authorities\AuthorityController@edit')->name('authority.update');
        Route::post('authority', 'Authorities\AuthorityController@store')->name('authority.store');
        Route::put('authority/{id}', 'Authorities\AuthorityController@update')->name('authority.update');
        Route::delete('authority/{id}', 'Authorities\AuthorityController@destroy')->name('authority.destroy');

    }
);
